#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

class Solution 
{
public:
	vector<int> sortedSquares(vector<int>& nums) 
	{
		for (size_t i = 0; i < nums.size(); i++) 
		{
			nums[i] = nums[i] * nums[i];
		}
		
		sort(nums.begin(), nums.end());
		
		return nums;
	}
};

int main() 
{
	Solution sol;
	vector<int> nums = {-2, -1, 0, 1, 2};
	vector<int> result = sol.sortedSquares(nums);
	
	cout << "平方后排序的结果: ";
	for (size_t i = 0; i < result.size(); i++) 
	{
		cout << result[i] << " ";
	}
	cout << endl;
	
	return 0;
}

